
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>zookeeper09事件监听机制watcher · Zookeeper</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="<yangxin19970404@163.com>">
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="zookeeper08javaApi连接zookeeper.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="zookeeper01概述.html">
            
                <a href="zookeeper01概述.html">
            
                    
                    zookeeper01概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="zookeeper02数据模型.html">
            
                <a href="zookeeper02数据模型.html">
            
                    
                    zookeeper02数据模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="zookeeper03单机安装.html">
            
                <a href="zookeeper03单机安装.html">
            
                    
                    zookeeper03单机安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="zookeeper04新增节点.html">
            
                <a href="zookeeper04新增节点.html">
            
                    
                    zookeeper04新增节点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="zookeeper05操作节点.html">
            
                <a href="zookeeper05操作节点.html">
            
                    
                    zookeeper05操作节点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="zookeeper06监听器.html">
            
                <a href="zookeeper06监听器.html">
            
                    
                    zookeeper06监听器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="zookeeper07acl权限控制.html">
            
                <a href="zookeeper07acl权限控制.html">
            
                    
                    zookeeper07acl权限控制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="zookeeper08javaApi连接zookeeper.html">
            
                <a href="zookeeper08javaApi连接zookeeper.html">
            
                    
                    zookeeper08javaApi连接zookeeper
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.10" data-path="zookeeper09事件监听机制watcher.html">
            
                <a href="zookeeper09事件监听机制watcher.html">
            
                    
                    zookeeper09事件监听机制watcher
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >zookeeper09事件监听机制watcher</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x4E8B;&#x4EF6;&#x76D1;&#x542C;&#x673A;&#x5236;">&#x4E8B;&#x4EF6;&#x76D1;&#x542C;&#x673A;&#x5236;</h3>
<ol>
<li><p>&#x6982;&#x5FF5;</p>
</li>
<li><p>zookeeper&#x63D0;&#x4F9B;&#x4E86;&#x6570;&#x636E;&#x7684;&#x53D1;&#x5E03;&#x8BA2;&#x9605;&#x529F;&#x80FD;,&#x591A;&#x4E2A;&#x8BA2;&#x9605;&#x8005;&#x53EF;&#x4EE5;&#x540C;&#x65F6;&#x76D1;&#x542C;&#x67D0;&#x4E00;&#x4E2A;&#x7279;&#x5B9A;&#x4E3B;&#x9898;&#x7684;&#x5BF9;&#x8C61;,&#x5F53;&#x8BE5;&#x4E3B;&#x9898;&#x5BF9;&#x8C61;&#x7684;&#x81EA;&#x8EAB;&#x72B6;&#x6001;&#x53D1;&#x751F;&#x53D8;&#x5316;&#x65F6;,&#x4F1A;&#x5B9E;&#x65F6;&#x901A;&#x77E5;&#x8BA2;&#x9605;&#x8005;</p>
</li>
<li><p>zookeeper&#x91C7;&#x7528;&#x4E86;Watcher&#x673A;&#x5236;&#x5B9E;&#x73B0;&#x53D1;&#x5E03;&#x8BA2;&#x9605;&#x529F;&#x80FD;,&#x8BE5;&#x673A;&#x5236;&#x5728;&#x88AB;&#x8BA2;&#x9605;&#x5BF9;&#x8C61;&#x53D1;&#x751F;&#x53D8;&#x5316;&#x65F6;&#x4F1A;&#x5F02;&#x6B65;&#x901A;&#x77E5;,&#x56E0;&#x6B64;&#x5BA2;&#x6237;&#x7AEF;&#x4E0D;&#x5FC5;&#x5728;Watcher&#x6CE8;&#x518C;&#x540E;&#x8F6E;&#x8BAD;&#x963B;&#x585E;,&#x4ECE;&#x800C;&#x51CF;&#x8F7B;&#x4E86;&#x5BA2;&#x6237;&#x7AEF;&#x7684;&#x538B;&#x529B;</p>
</li>
<li><p>Watcher&#x673A;&#x5236;&#x5B9E;&#x9645;&#x4E0A;&#x4E0E;&#x89C2;&#x5BDF;&#x8005;&#x6A21;&#x5F0F;&#x7C7B;&#x4F3C;,&#x4E5F;&#x53EF;&#x4EE5;&#x770B;&#x505A;&#x4E00;&#x79CD;&#x89C2;&#x5BDF;&#x8005;&#x6A21;&#x5F0F;&#x5728;&#x5206;&#x5E03;&#x5F0F;&#x573A;&#x666F;&#x4E0B;&#x5B9E;&#x73B0;&#x65B9;&#x6CD5;</p>
</li>
<li><p>watcher&#x67B6;&#x6784;</p>
</li>
</ol>
<p>watcher&#x5B9E;&#x73B0;&#x7531;&#x4E09;&#x4E2A;&#x90E8;&#x5206;&#x7EC4;&#x6210;:</p>
<ul>
<li>zookeeper&#x670D;&#x52A1;&#x7AEF;</li>
<li>zookeeper&#x5BA2;&#x6237;&#x7AEF;</li>
<li>&#x5BA2;&#x6237;&#x7AEF;&#x7684;ZKWatcherManager&#x5BF9;&#x8C61;</li>
</ul>
<p><img src="./imgs/&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20210329204342.png" alt=""></p>
<ol>
<li>watcher&#x7279;&#x6027;</li>
</ol>
<p><img src="./imgs/&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20210329204434.png" alt=""></p>
<p><img src="./imgs/&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20210329204625.png" alt=""></p>
<h1 id="&#x5148;&#x653E;&#x4E00;&#x653E;&#x56DE;&#x6765;&#x7EE7;&#x7EED;&#x5B66;&#x4E60;">&#x5148;&#x653E;&#x4E00;&#x653E;,&#x56DE;&#x6765;&#x7EE7;&#x7EED;&#x5B66;&#x4E60;...</h1>
<p><a href="https://www.bilibili.com/video/BV1M741137qY?p=29" target="_blank">https://www.bilibili.com/video/BV1M741137qY?p=29</a></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="zookeeper08javaApi连接zookeeper.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: zookeeper08javaApi连接zookeeper">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"zookeeper09事件监听机制watcher","level":"1.10","depth":1,"previous":{"title":"zookeeper08javaApi连接zookeeper","level":"1.9","depth":1,"path":"zookeeper08javaApi连接zookeeper.md","ref":"zookeeper08javaApi连接zookeeper.md","articles":[]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"<yangxin19970404@163.com>","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Zookeeper","language":"zh-hans","gitbook":"3.2.3","description":"Zookeeper > 分布式服务管理框架"},"file":{"path":"zookeeper09事件监听机制watcher.md","mtime":"2021-03-29T12:50:06.933Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-04-17T08:10:28.423Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

